#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main()
{ 
  close(1);
  int fd = open("log.txt", O_CREAT | O_TRUNC | O_WRONLY, 0644);
  printf("%d\n",fd);
  fflush(stdout);
  if(fd < 0)
  {
    perror("open failed : ");
    return 1;
  }

  const char* str = "hello world\n";
  write(1, str, strlen(str));
  close(1);

  return 0;
}
